---
title: "Analysis Script"
author: "Martin Naunov"
date: "01/03/2023"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning=FALSE,message=FALSE)
setwd("/Users/martinnaunov/Desktop/Desktop - Martin’s MacBook Pro (2)/Persuasion/2_workingdata")
```

```{r, include=FALSE}
library(dplyr)
library(data.table) 
library(modelsummary)
library(gridExtra)
library(ggplot2)
library(grid)
library(lme4)
library(lmerTest)
library(stargazer) 
library(marginaleffects)
library(psych)
rm(list=ls())
```


```{r}
setwd("/Users/martinnaunov/Desktop/Desktop - Martin’s MacBook Pro (2)/Persuasion/2_workingdata")
library(dplyr)
df2 <- read.csv("working_data_final_sr2.csv")

df2 <- read.csv("working_data_final_sr2.csv") %>% 
  dplyr::select(pre, post, side, quarkelt1, quarkelt2, respid, respondent,
                partyid_7, issue, affpol, att_strength, pol_intr_full, pol_intr, 
                pol_know_avg, persp_tak, nfc, self_est, female, race, edu, 
                income, age, mlengthwords, mlengthchar, time, common_ground, 
                personal_rev, specific_fact, respondent, 
                task_persuade, task_expect, movement, binary, partyid_7_rec,edu_rec,age_rec,income_rec,race_rec, female_main, female_alt, anchor, controlcond) %>% 
  mutate_at(vars(pre, post, quarkelt1, quarkelt2, partyid_7, partyid_7_rec, affpol, 
                 att_strength, pol_intr_full, pol_intr, pol_know_avg, 
                 persp_tak, nfc,  self_est, income, age, mlengthwords, 
                 mlengthchar, time, task_persuade, age_rec, income_rec),
            .funs = as.numeric) %>% 
  mutate_at(vars(side, respid, respondent, 
                 issue, female, race, edu, race_rec, edu_rec, female_main, female_alt, common_ground,
                 personal_rev, specific_fact, task_expect, movement, binary, anchor, controlcond,), .funs = as.factor)

  
```



## Persuasion Change Graph
##Figure A.5.2: Receiver Persuasion, by Sender’s Issue Side (Study 2)


```{r}

df2 <-df2 %>% 
  mutate(change2 = quarkelt2 - quarkelt1)


# Plot by issue side
df2 <- df2 %>% 
  group_by(side)

# Recode the side variable for graphing
df2$side <- factor(df2$side, levels = c("env_cons", "imm_cons", "trans_cons", 
                             "env_lib", "imm_lib", "trans_lib"))
# Change side labels for title in graphs
df2$side <- recode(df2$side, 
                  "env_cons" = "Conservative Energy",
                  "imm_cons" = "Conservative Immigration", 
                  "trans_cons" = "Conservative Transgender", 
                  "env_lib" = "Liberal Energy", 
                  "imm_lib" = "Liberal Immigration", 
                  "trans_lib" = "Liberal Transgender")

plot1 <- by(df2, df2$side, function(sub){
  ggplot(sub, aes(change2)) +
        geom_histogram(aes(y = (..count..)/sum(..count..)),
                   color="black", fill="gray", bins = 20) +
        ggtitle(sub$side[[1]]) + 
    scale_x_continuous(breaks = seq(-10, 10 , 5), 
                       limits = c(-10.5, 10.5)) + 
    scale_y_continuous(labels = scales::percent, 
                       breaks = seq(0,.8, .2), 
                       limits = c(-0.05, .70)) + 
  theme_bw() + 
  theme(plot.title = element_text(hjust = 0.5, size = 9, face = "bold") , 
          axis.title.x = element_blank(), 
          axis.title.y = element_blank())
  })

plot1 <- grid.arrange(arrangeGrob(grobs = plot1, ncol = 3, 
                         bottom = textGrob("Persuasion",
                                           gp = gpar(fontsize = 10,
                                                     fontface = "bold")),
                         left = textGrob("Percent",
                                         rot = 90,
                                         gp = gpar(fontsize = 10, 
                                                   fontface = "bold")),
                         ))

```


#Main text Figure 1: Receiver Persuasion, by Issue and Argument Exposure

```{r}
# Load necessary libraries
library(dplyr)
library(ggplot2)
library(gridExtra)
library(grid)


df2 <-df2 %>% 
  mutate(change2 = quarkelt2 - quarkelt1)

# Create a new variable issue_control based on issue and controlcond
df2 <- df2 %>%
  mutate(issue_control = paste(issue, controlcond, sep = "_"))

# Create a new variable for simplified issue labels
df2 <- df2 %>%
  mutate(issue_label = recode(issue, 
                              'env' = 'Environment', 
                              'imm' = 'Immigration', 
                              'trans' = 'Transgender Rights'))

# Plot by issue_control
df2 <- df2 %>% 
  group_by(issue_control)

# Recode the issue_control variable for graphing
df2$issue_control <- factor(df2$issue_control, levels = c('env_0', 'imm_0', 'trans_0', 
                                                          'env_1', 'imm_1', 'trans_1'))

# Create the plot

plot1 <- by(df2, df2$issue_control, function(sub){
  ggplot(sub, aes(change2)) +
        geom_histogram(aes(y = (..count..)/sum(..count..)),
                   color="black", fill="gray", bins = 20) +
          facet_grid(controlcond ~ issue_label, labeller = labeller(controlcond = c('0' = 'Argument Treatment Condition', '1' = 'Control Condition'))) +
    scale_x_continuous(breaks = seq(-10, 10 , 5), 
                       limits = c(-10.5, 10.5)) + 
    scale_y_continuous(labels = scales::percent, 
                       breaks = seq(0,.8, .2), 
                       limits = c(-0.05, .90)) +
  theme_bw() +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        strip.text.x = element_text(size = 8),
        strip.text.y = element_text(size = 8))
  })

plot1 <- grid.arrange(arrangeGrob(grobs = plot1, ncol = 3, 
                         bottom = textGrob("Persuasion",
                                           gp = gpar(fontsize = 10,
                                                     fontface = "bold")),
                         left = textGrob("Percent",
                                         rot = 90,
                                         gp = gpar(fontsize = 10, 
                                                   fontface = "bold")),
                         ))


# Print the plot
print(plot1)

# Save the plot
ggsave('fg1_plot.png', plot1, width = 8, height = 4.5, dpi = 1200)


```


#How much attitude change do we observe?

# The following code replicates the figures and calculations presented in the 
# second paragraph of the "Citizens Can Persuade" section in the main text.
# Specifically, it reproduces the percentages of opinion stability, movement 
# in the Sender's intended direction, and movement away from the Sender, as 
# well as the net persuasion values reported for Study 2

```{r}

#Calculating % Change (-1 (Backhlash), 0 (No change), 1 (Persuasion) in the Treatment Condition, i.e. respondents exposed to an Argument)
summary(df2$movement[df2$controlcond == 0])
table(df2$movement[df2$controlcond == 0])


#  -1    0    1 NA's 
# 786 3498 1739   26 

#No Change (0.5807737)
3498/(786 + 3498 + 1739)

#Persuasion (0.2887265)
1739/(786 + 3498 + 1739)

#Backlash (0.1304998)
786/(786 + 3498 + 1739)


#Calculating % Change (-1 (Backhlash), 0 (No change), 1 (Persuasion) in the Control Condition, i.e. respondents NOT exposed to an Argument)
summary(df2$movement[df2$controlcond == 1])
table(df2$movement[df2$controlcond == 1])

 # -1    0    1 NA's 
# 164 1148  167   11 


#No Change (0) 1148/(164+1148+167) (0.7762001)
#Persuasion (1) 167/(164+1148+167) (0.1129141)
#Backlash (-1) 164/(164+1148+167) (0.1108857)

```

# The following code replicates the analysis presented in the third paragraph 
# of the "Citizens Can Persuade" section, examining the effect of anchoring 
# on attitude change in Study 2. Specifically, it reproduces the negative 
# effect of anchoring (β = -0.12; p = 0.02), demonstrating that anchored 
# responses represent a more demanding test of attitude change.
```{r}
#ANCHORING & CONTROL CONDITION

summary(lmer(quarkelt2 ~ quarkelt1 + anchor +
                                  issue + (1|respid) + (1|respondent), 
                                data =subset (df2, controlcond==0)))

#anchor1       -0.11567    0.05286 2022.50523  -2.188   0.0288 *  


summary(lmer(quarkelt2 ~ quarkelt1 + anchor + controlcond +
                                  issue + (1|respid) + (1|respondent), 
                                data = df2))


```

### Range Standardize Variables
```{r}
range01 <- function(x, ...){(x - min(x, ...)) / (max(x, ...) - min(x, ...))}

# Note that political knowledge and interest already vary between 0 and 1.
df2$affpol <- range01(df2$affpol, na.rm = T)
df2$att_strength <- range01(df2$att_strength, na.rm = T)
df2$persp_tak <- range01(df2$persp_tak, na.rm = T)
df2$nfc <- range01(df2$nfc, na.rm = T)
df2$self_est <- range01(df2$self_est, na.rm = T)
df2$mlengthwords <- range01(df2$mlengthwords, na.rm = T)
df2$mlengthchar <- range01(df2$mlengthchar, na.rm = T)
df2$time <- range01(df2$time, na.rm = T)
df2$age <- range01(df2$age, na.rm = T)
df2$income <- range01(df2$income, na.rm = T)
```


## Main Analysis: Sender Characteristics

```{r}
df2$movement_3 <- df2$movement
df2$movement_3 <- as.ordered(df2$movement_3)
```

### Main text analyses
## Party ID Intensity
```{r}
### Make a new variable called partyid_cat where a 1 indicates a pure independent
### (4 in partyid_7), 2 indicates a leaner (5 and 3 in partyid_7), 3 indicates 
### a not strong partisan (6 and 2 in partyid_7) and 4 indicates a strong partisan
### (7 and 1 in partyid_7)

df2$partyid_cat <- NA

df2$partyid_cat[df2$partyid_7 == 4] <- 1
df2$partyid_cat[df2$partyid_7 == 3 | df2$partyid_7 == 5] <- 2
df2$partyid_cat[df2$partyid_7 == 2 | df2$partyid_7 == 6] <- 3
df2$partyid_cat[df2$partyid_7 == 1 | df2$partyid_7 == 7] <- 4

df2$partyid_cat <- as.factor(df2$partyid_cat)
```


```{r}
# The following code is used for the analysis reported in Footnote 13 of the main text.
# "Receivers in Study 2’s control group exhibited significantly ..."

control_effect <-  lm(quarkelt2 ~ quarkelt1 + controlcond, data = df2)

summary(control_effect)


```

```{r}

df2$d_env <- ifelse(df2$quarkelt1 == 5 & df2$issue == "env", 1, 0)
df2$d_imm <- ifelse(df2$quarkelt1 == 5 & df2$issue == "imm", 1, 0)
df2$d_trans <- ifelse(df2$quarkelt1 == 5 & df2$issue == "trans", 1, 0)


#Control Condition Effect Including Dummies for those starting neutral

control_effect_issue <-  lm(quarkelt2 ~ quarkelt1 + controlcond + issue, data = df2)

summary(control_effect_issue)

control_effect_dummies <-  lm(quarkelt2 ~ quarkelt1 + controlcond + issue + d_env + d_imm + d_trans, data = df2)

summary(control_effect_dummies)


```


```{r}
#Creating a dataframe excluding control condition
df3 <- subset(df2, controlcond != 1)

```


```{r}
anchor_effect <-  lm(quarkelt2 ~ quarkelt1 + anchor, data = df3)

summary(anchor_effect)

anchor_issue_effect <-  lm(quarkelt2 ~ quarkelt1 + anchor*issue , data = df3)

summary(anchor_issue_effect)

```

#Calculating average persuasion for each argument (Discussion footnote)
```{r}
# The following code is used for the Study 2 analysis reported in Footnote 20 of the main text.
# "Rather than summarizing across message presentations ..."

df3 <-df3 %>% 
  mutate(change3 = quarkelt2 - quarkelt1)

av_pers <- df3 %>% 
  group_by(respid) %>% 
  summarise_at(vars(change3),
               list(mean = mean), na.rm = T) %>% 
  as.list(.)

length(which(av_pers$mean == 0)) # (0.0906801) 36/(36 + 46 + 315)
length(which(av_pers$mean < 0)) # (0.115869) 46/(36 + 46 + 315)
length(which(av_pers$mean > 0)) # (0.7934509) 315/(36 + 46 + 315)

```


## Issue Side Means and Standard Errors
#Table 3: Persuasion by Issue Side
```{r}
# Make a change2 variable that indicates any persuasion that takes place
df3 <-df3 %>% 
  mutate(change3 = quarkelt2 - quarkelt1)

# Make a function to calculate the standard error
se <- function(x, ...) sqrt(var(x, ...)/length(x))

# Calculate the standard error and mean by issue side
df3 %>% 
  group_by(side) %>% 
  summarise_at(vars(change3),
               list(mean = mean, se = se), na.rm = T) %>% 
  as.list(.)

## Code to assess the null hypothesis that liberal and conservative senders are equally persuasive, within a given issue.

# Environment
df_env <- df3 %>% 
  filter(side %in% c("Conservative Energy", "Liberal Energy")) %>% 
  group_by(side) 

summary(lm(change3 ~ side, data = df_env))

rm(df_env)

# Immigration 
df_imm <- df3 %>% 
  filter(side %in% c("Conservative Immigration", "Liberal Immigration")) %>% 
  group_by(side) 

summary(lm(change3 ~ side, data = df_imm))

rm(df_imm)

# Transgender Rights 
df_trans <- df3 %>% 
  filter(side %in% c("Conservative Transgender", "Liberal Transgender")) %>% 
  group_by(side) 

summary(lm(change3 ~ side, data = df_trans))

rm(df_trans)

```

#Attitude Change expressed in terms of standard deviations of the outcome
```{r}
mean_change_overall <- mean(df3$change2, na.rm = TRUE)
sd_outcome_overall <- sd(df3$change2, na.rm = TRUE)

# Calculate the attitude change in standard deviations of the outcome
change_in_sd_overall <- mean_change_overall / sd_outcome_overall

change_in_sd_overall
#0.3137633

```


# Table 3: Persuasion by Issue Side (Study 2)
# Table A.5.1 (Attitude Change in Standard Deviations, by Issue Side (Study 2)
## Calculate the mean change, standard error, and standard deviation of the outcome

```{r}
library(dplyr)

df_summary <- df3 %>% 
  group_by(side) %>% 
  summarise(
    mean_change = mean(change2, na.rm = TRUE),
    se_change = sd(change2, na.rm = TRUE) / sqrt(n()),
    sd_outcome = sd(change2, na.rm = TRUE)
  )

# Calculate the attitude change in standard deviations of the outcome
df_summary <- df_summary %>%
  mutate(
    change_in_sd = mean_change / sd_outcome
  )

# Print the results
df_summary

```



# Table 4: Variance Explained by Various Factors (Study 2)
## R-Squared for sender, receiver and issue side fixed effects


```{r}
# Sender fixed-effects

mod1 <- lm(quarkelt2 ~ respid, data = df3)
summary(mod1)$r.squared


# Receiver Fixed effects
mod2 <- lm(quarkelt2 ~ respondent, data = df3)
summary(mod2)$r.squared

# Issue-side Fixed Effects 
mod3 <- lm(quarkelt2 ~ side, data = df3)
summary(mod3)$r.squared


```



#Below is code for:
# Table 5: Hypothesis tests (Study 2)
# Table A.6.3: Hypothesis tests, Study 2 (H1-H6)
# Table A.6.4: Hypothesis tests, Study 2 (H7-H14)

#H1: Need for cognition is associated with greater persuasion
# As noted in the main text (see, e.g., the note under Table 5), the p-values in Table 2 reflect one-tailed tests
# given that our hypotheses are pre-registered and directional. 
# Accordingly, the one-tailed test p-values are calculated by dividing the p-values generated by the lmer function by 2.

#ANALYSES WITH COOK'S DISTANCE REMOVAL 

```{r}
df2 <- subset(df2, controlcond != 1)

```

#H1: Need for cognition is associated with greater persuasion
```{r}
fit_nfc <- lmer(quarkelt2 ~ quarkelt1 + nfc + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)
cooks_h3 <- as.data.frame(cooks.distance(fit_nfc))

df_estimation_3 <- df2[as.numeric(rownames(cooks_h3)), ]


fit_nfc_est <- lmer(quarkelt2 ~ quarkelt1 + nfc + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_3)
summary(fit_nfc_est)

cooks_h3 <- as.data.frame(cooks.distance(fit_nfc_est))

mean(cooks_h3$`cooks.distance(fit_nfc_est)`) + 2*sd(cooks_h3$`cooks.distance(fit_nfc_est)`)
#0.115403


df_reduced_nfc <- df_estimation_3[cooks_h3$`cooks.distance(fit_nfc_est)` < 0.115403,]

summary(lmer(quarkelt2 ~ quarkelt1 + nfc + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_nfc))

fit_nfc_cooks <- lmer(quarkelt2 ~ quarkelt1 + nfc + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_nfc)

#nfc            0.14332    0.08204  263.14030   1.747 0.081820 .  

#p=0.04091 (0.081820/2)
```

# H2: Perspective taking ability is associated with greater persuasion

```{r}
library(lmerTest)

fit_persptak <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)
summary(fit_persptak)


cooks_h8 <- as.data.frame(cooks.distance(fit_persptak))

df_estimation_8 <- df2[as.numeric(rownames(cooks_h8)), ]


fit_persptak_est <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_8)
summary(fit_persptak_est)


cooks_h8 <- as.data.frame(cooks.distance(fit_persptak_est))


mean(cooks_h8$`cooks.distance(fit_persptak_est)`) + 2*sd(cooks_h8$`cooks.distance(fit_persptak_est)`)
#0.1155261

df_reduced_persptak <- df_estimation_8[cooks_h8$`cooks.distance(fit_persptak_est)` < 0.1155261,]

fit_persptak_cooks <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_persptak)

summary(fit_persptak_cooks)

#persp_tak      0.15326    0.09106  234.94264   1.683 0.093713 .  

#p=0.0468565 (0.093713/2)


```

# H3: Senders who use personal appeals are more persuasive

```{r}
fit_personal_rev <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2) 
summary(fit_personal_rev)

cooks_h9 <- as.data.frame(cooks.distance(fit_personal_rev))

df_estimation_9 <- df2[as.numeric(rownames(cooks_h9)), ]


fit_personal_rev_est <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_9)
summary(fit_personal_rev_est)


cooks_h9 <- as.data.frame(cooks.distance(fit_personal_rev_est))


mean(cooks_h9$`cooks.distance(fit_personal_rev_est)`) + 2*sd(cooks_h9$`cooks.distance(fit_personal_rev_est)`)
#0.1148014

df_reduced_personal_rev <- df_estimation_9[cooks_h9$`cooks.distance(fit_personal_rev_est)` < 0.1148014,]


fit_personal_rev_cooks <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_personal_rev)


summary(fit_personal_rev_cooks)

#personal_rev1    0.22620    0.06778  310.69372   3.337 0.000949 ***

```


# H4: Senders who highlight common ground are more persuasive

```{r}
fit_common_ground <- lmer(quarkelt2 ~ quarkelt1 + common_ground + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)
summary(fit_common_ground)

cooks_h10 <- as.data.frame(cooks.distance(fit_common_ground))

df_estimation_10 <- df2[as.numeric(rownames(cooks_h10)), ]


fit_cm_est <- lmer(quarkelt2 ~ quarkelt1 + common_ground + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_10)
summary(fit_cm_est)

cooks_h10 <- as.data.frame(cooks.distance(fit_cm_est))


mean(cooks_h10$`cooks.distance(fit_cm_est)`) + 2*sd(cooks_h10$`cooks.distance(fit_cm_est)`)
#0.1133729

df_reduced_cm <- df_estimation_10[cooks_h10$`cooks.distance(fit_cm_est)` < 0.1133729,]


fit_cm_cooks <- lmer(quarkelt2 ~ quarkelt1 + common_ground + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_cm)

summary(lmer(quarkelt2 ~ quarkelt1 + common_ground + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_cm))

#common_ground1  1.638e-01  4.421e-02  2.417e+02   3.706 0.000261 ***


```


# H5: Long messages are more persuasive

```{r}
# Message Length (in words)
fit_length <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)
summary(fit_length)

cooks_h11 <- as.data.frame(cooks.distance(fit_length))

df_estimation_11 <- df2[as.numeric(rownames(cooks_h11)), ]


fit_length_est <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_11)
summary(fit_length_est)

cooks_h11 <- as.data.frame(cooks.distance(fit_length_est))


mean(cooks_h11$`cooks.distance(fit_length_est)`) + 2*sd(cooks_h11$`cooks.distance(fit_length_est)`)
#0.1146123

df_reduced_length <- df_estimation_11[cooks_h11$`cooks.distance(fit_length_est)` < 0.1146123,]


fit_length_cooks <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_length)

summary(lmer(quarkelt2 ~ quarkelt1 + mlengthwords + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_length))

#mlengthwords    0.40445    0.09613  287.57141   4.207 3.46e-05 ***




```


# H6: Messages that took more time to write are more persuasive

```{r}
# Time (in seconds)
fit_time <- lmer(quarkelt2 ~ quarkelt1 + time + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)

cooks_h12 <- as.data.frame(cooks.distance(fit_time))

df_estimation_12 <- df2[as.numeric(rownames(cooks_h12)), ]


fit_time_est <- lmer(quarkelt2 ~ quarkelt1 + time + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_12)

cooks_h12 <- as.data.frame(cooks.distance(fit_time_est))


mean(cooks_h12$`cooks.distance(fit_time_est)`) + 2*sd(cooks_h12$`cooks.distance(fit_time_est)`)
#0.1154306

df_reduced_time <- df_estimation_12[cooks_h12$`cooks.distance(fit_time_est)` < 0.1154306,]


fit_time_cooks <- lmer(quarkelt2 ~ quarkelt1 + time + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_time)

summary(lmer(quarkelt2 ~ quarkelt1 + time + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_time))

#time           0.29587    0.12457  259.39349   2.375  0.01827 *  
#p=0.009135 (0.01827/2)



```



```{r}
# Length AND time
# Used to replicate calculations in Footnote 19 ("When we enter both...")

fit_lengthtime <-  lmer(quarkelt2 ~ quarkelt1 + issue + mlengthwords + time + anchor +
                          (1|respid) + (1|respondent), data = df2)
summary(fit_lengthtime)

cooks_lengthtime <- as.data.frame(cooks.distance(fit_lengthtime))

df_estimation_lt <- df2[as.numeric(rownames(cooks_lengthtime)), ]


fit_lengthtime_est <- lmer(quarkelt2 ~ quarkelt1 + issue + mlengthwords + time + anchor +
                          (1|respid) + (1|respondent), data = df_estimation_lt)

cooks_lengthtime <- as.data.frame(cooks.distance(fit_lengthtime_est))


mean(cooks_lengthtime$`cooks.distance(fit_lengthtime_est)`) + 2*sd(cooks_lengthtime$`cooks.distance(fit_lengthtime_est)`)
#0.09848572

df_reduced_lt <- df_estimation_lt[cooks_lengthtime$`cooks.distance(fit_lengthtime_est)` < 0.09848572,]


summary(lmer(quarkelt2 ~ quarkelt1 + issue + mlengthwords + time + anchor +
                          (1|respid) + (1|respondent), data = df_reduced_lt))

#mlengthwords  4.042e-01  1.140e-01  2.659e+02   3.546 0.000462 ***
#time          7.166e-04  1.453e-01  2.398e+02   0.005 0.996068    

#p-value for time = 0.498 (0.996068/2)

```

#H7: Independent leaners more persuasive arguments than pure independents
```{r}
# Leaners better at persuading relative to pure independents

df_partyintensity_1_2 <- subset(df2, partyid_cat == 1 | partyid_cat == 2)


fit_partyintensity_lean <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data =df_partyintensity_1_2)

summary(fit_partyintensity_lean)


cooks_h6 <- as.data.frame(cooks.distance(fit_partyintensity_lean))

df_estimation_6 <- df_partyintensity_1_2[as.numeric(rownames(cooks_h6)), ]


fit_partyint_lean_est <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data = df_estimation_6)

summary(fit_partyint_lean_est)

cooks_h6 <- as.data.frame(cooks.distance(fit_partyint_lean_est))

mean(cooks_h6$`cooks.distance(fit_partyint_lean_est)`) + 2*sd(cooks_h6$`cooks.distance(fit_partyint_lean_est)`)


df_reduced_partyint_lean <- df_estimation_6[cooks_h6$`cooks.distance(fit_partyint_lean_est)` < 0.2372019,]

summary(lmer(quarkelt2 ~ quarkelt1 + partyid_cat + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_partyint_lean))

fit_partyint_lean_cooks <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_partyint_lean)

#partyid_cat2  1.363e-01  1.051e-01  6.977e+01   1.297  0.19901

#p=0.099505 (0.19901/2)
```

#H8: Strong party identifiers less persuasive than weak dentifiers
```{r}

library(lmerTest)

df_partyintensity_3_4 <- subset(df2, partyid_cat == 3 | partyid_cat == 4)

fit_partyintensity_sw <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data = df_partyintensity_3_4)

summary(fit_partyintensity_sw)


cooks_h5 <- as.data.frame(cooks.distance(fit_partyintensity_sw))

df_estimation_5 <- df_partyintensity_3_4[as.numeric(rownames(cooks_h5)), ]


fit_partyint_est <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data = df_estimation_5)

summary(fit_partyint_est)

cooks_h5 <- as.data.frame(cooks.distance(fit_partyint_est))

mean(cooks_h5$`cooks.distance(fit_partyint_est)`) + 2*sd(cooks_h5$`cooks.distance(fit_partyint_est)`)
#0.1440363

df_reduced_partyint <- df_estimation_5[cooks_h5$`cooks.distance(fit_partyint_est)` < 0.1440363,]

summary(lmer(quarkelt2 ~ quarkelt1 + partyid_cat + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_partyint))

fit_partyint_cooks <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_partyint)

#partyid_cat4   -0.02504    0.04634  196.29481  -0.540   0.5896    

#p=0.2948 (0.5896/2)

```




#H9: Affective polarization is associated with lower persuasiveness

```{r}
library(lme4)

fit_affpol <- lmer(quarkelt2 ~ quarkelt1 + affpol + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)
summary(fit_affpol)

cooks_h7 <- as.data.frame(cooks.distance(fit_affpol))

df_estimation_7 <- df2[as.numeric(rownames(cooks_h7)), ]


fit_affpol_est <- lmer(quarkelt2 ~ quarkelt1 + affpol + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data = df_estimation_7)

summary(fit_affpol_est)

cooks_h7 <- as.data.frame(cooks.distance(fit_affpol_est))

mean(cooks_h7$`cooks.distance(fit_affpol_est)`) + 2*sd(cooks_h7$`cooks.distance(fit_affpol_est)`)
#0.1161588

df_reduced_affpol <- df_estimation_7[cooks_h7$`cooks.distance(fit_affpol_est)` < 0.1161588,]

summary(lmer(quarkelt2 ~ quarkelt1 + affpol + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_affpol))


fit_affpol_cooks <- lmer(quarkelt2 ~ quarkelt1 + affpol + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_affpol)

#affpol       3.311e-03  6.287e-02  2.576e+02   0.053  0.95804    

#p=0.47902 (0.95804/2)
```


#H10: Interest in politics is associated with greater persuasiveness

```{r}

fit_polintr2 <-  lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)

cooks_h2 <- as.data.frame(cooks.distance(fit_polintr2))

df_estimation_2 <- df2[as.numeric(rownames(cooks_h2)), ]


fit_polintr_est <- lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_2)

cooks_h2 <- as.data.frame(cooks.distance(fit_polintr_est))

mean(cooks_h2$`cooks.distance(fit_polintr_est)`) + 2*sd(cooks_h2$`cooks.distance(fit_polintr_est)`)
#0.1163194


df_reduced_pi <- df_estimation_2[cooks_h2$`cooks.distance(fit_polintr_est)` < 0.1163194,]

fit_pi_cooks <- lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_pi)

summary(lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_pi))

#pol_intr_full    0.04179    0.08051  264.67478   0.519  0.60412    

#p=0.30206 (0.60412/2)
```


# H11: Political knowledge is associated with greater persuasiveness
```{r}

fit_polknow <-  lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)

summary(fit_polknow)

cooks_h1 <- as.data.frame(cooks.distance(fit_polknow))

df_estimation_1 <- df2[as.numeric(rownames(cooks_h1)), ]


fit_polknow_est <- lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_1)

cooks_h1 <- as.data.frame(cooks.distance(fit_polknow_est))

mean(cooks_h1$`cooks.distance(fit_polknow_est)`) + 2*sd(cooks_h1$`cooks.distance(fit_polknow_est)`)
#0.1174555

df_reduced_pk <- df_estimation_1[cooks_h1$`cooks.distance(fit_polknow_est)` < 0.1174555,]

fit_pk_cooks <- lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_pk)

summary(fit_pk_cooks)



```



#H12: Senders who mention specific facts are more persuasive

```{r}
fit_specific_fact <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2) 
summary(fit_specific_fact)

cooks_h4 <- as.data.frame(cooks.distance(fit_specific_fact))

df_estimation_4 <- df2[as.numeric(rownames(cooks_h4)), ]


fit_fact_est <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_4)
summary(fit_fact_est)

cooks_h4 <- as.data.frame(cooks.distance(fit_fact_est))

mean(cooks_h4$`cooks.distance(fit_fact_est)`) + 2*sd(cooks_h4$`cooks.distance(fit_fact_est)`)
#0.1140642


df_reduced_fact <- df_estimation_4[cooks_h4$`cooks.distance(fit_fact_est)` < 0.1140642,]


fit_fact_cooks <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_fact)

summary(fit_fact_cooks)

#specific_fact1    0.08360    0.07166  251.18504   1.167  0.24447    

#p=0.122235 (0.24447/2)
```



#H13: Self Esteem
```{r}
library(lmerTest)

fit_selfest <- lmer(quarkelt2 ~ quarkelt1 + self_est + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)

summary(fit_selfest)

cooks_selfest1 <- as.data.frame(cooks.distance(fit_selfest))

df_estimation_selfest1 <- df2[as.numeric(rownames(cooks_selfest1)), ]


fit_selfest1_est <- lmer(quarkelt2 ~ quarkelt1 + self_est + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_selfest1)
summary(fit_selfest1_est)


cooks_selfest1 <- as.data.frame(cooks.distance(fit_selfest1_est))


mean(cooks_selfest1$`cooks.distance(fit_selfest1_est)`) + 2*sd(cooks_selfest1$`cooks.distance(fit_selfest1_est)`)
#0.1151942

df_reduced_selfest1 <- df_estimation_selfest1[cooks_selfest1$`cooks.distance(fit_selfest1_est)` < 0.1151942,]

fit_selfest_1_cdr <- lmer(quarkelt2 ~ quarkelt1 + self_est + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_selfest1)

summary(fit_selfest_1_cdr)

#self_est      -0.12859    0.07991  295.91188  -1.609 0.108634    

#p=0.054317 (0.108634/2)


```



#H14: Issue Attitude Extremity
```{r}

fit_attstrength <-  lmer(quarkelt2 ~ quarkelt1 + att_strength + issue + anchor +
                           (1|respid)+ (1|respondent), data = df2)

summary(fit_attstrength)

cooks_attstrength <- as.data.frame(cooks.distance(fit_attstrength))

df_estimation_attstrength <- df2[as.numeric(rownames(cooks_attstrength)), ]


fit_attstrength_est <- lmer(quarkelt2 ~ quarkelt1 + att_strength + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_estimation_attstrength)
summary(fit_attstrength_est)


cooks_attstrength <- as.data.frame(cooks.distance(fit_attstrength_est))


mean(cooks_attstrength$`cooks.distance(fit_attstrength_est)`) + 2*sd(cooks_attstrength$`cooks.distance(fit_attstrength_est)`)
#0.1162015

df_reduced_attstrength <- df_estimation_attstrength[cooks_attstrength$`cooks.distance(fit_attstrength_est)` < 0.1162015,]


fit_attstrength_cooks <- lmer(quarkelt2 ~ quarkelt1 + att_strength + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_attstrength)

summary(lmer(quarkelt2 ~ quarkelt1 + att_strength + issue + anchor +
                           (1|respid)+ (1|respondent), data = df_reduced_attstrength))

#att_strength -7.063e-02  5.684e-02  2.643e+02  -1.243  0.21509    

#p = 0.107545 (0.21509/2)
```


#Table A.6.3: Hypothesis Tests, Study 2 (H1-H6)
```{r}

library("texreg")

texreg(l = list(fit_nfc_cooks, fit_persptak_cooks, fit_personal_rev_cooks, fit_cm_cooks, fit_length_cooks, fit_time_cooks),stars = c(0.2, 0.1, 0.02))

```

#Table A.6.4: Hypothesis Tests, Study 2 (H7-H14)
```{r}
library("texreg")

texreg(l = list(fit_partyint_cooks, fit_partyint_lean_cooks, fit_affpol_cooks, fit_pi_cooks, fit_pk_cooks, fit_fact_cooks, fit_selfest_1_cdr, fit_attstrength_cooks),stars = c(0.2, 0.1, 0.02))
```


##DO PERSUASIVE PEOPLE KNOW THEY CAN PERSUADE

```{r}
# The following code replicates the calculations for Study 2 presented in the 
# "Do persuasive people know that they are persuasive?" section of the main text.

# Expected persuasion (Continuous)
df2$task_persuade <- range01(df2$task_persuade, na.rm = T)

fit_task_persuade <-  lmer(quarkelt2 ~ quarkelt1 + task_persuade + issue + anchor +
                             (1|respid) + (1|respondent), data = df2)
summary(fit_task_persuade)

#task_persuade -1.503e-01  1.186e-01  2.861e+02  -1.267  0.20633    

df2 <- within(df2, task_expect <- relevel(task_expect, ref = 2))

fit_expect <-  lmer(quarkelt2 ~ quarkelt1 + task_expect + issue + anchor +
                      (1|respid) + (1|respondent), data = df2)

summary(fit_expect)

#task_expect1   -0.02062    0.09205  284.33481  -0.224  0.82293    
#task_expect3   -0.03082    0.06854  251.52846  -0.450  0.65334 

```

#Table A.7.2: Self-knowledge About Persuasion (Study 2)
```{r}

library("texreg")

texreg(l = list(fit_task_persuade, fit_expect),stars = c(0.001, 0.01, 0.05))

```



# SI SECTION 8: RESULTS FROM PRE-REGISTERED CHECKS

# Below code can be used to replicate figures in Table A.8.2: Hypothesis Tests Withot Cook's D-Based Exclusions (Study 2)

# the one-tailed test p-values are calculated by dividing the p-values generated by the lmer or clmm functions by 2.

# H1 Need for cognition is associated with greater persuasion
```{r}
fit_nfc <- lmer(quarkelt2 ~ quarkelt1 + nfc + issue + anchor +
                           (1|respid)+ (1|respondent), data = df3)
summary(fit_nfc)

nfc_bnp <- ordinal::clmm(movement_3 ~ nfc + issue + anchor + (1|respid) + (1|respondent),
                              data = df3, link='logit')
summary(nfc_bnp)


```

# H2 Perspective taking ability is associated with greater persuasion

```{r}
fit_persptak <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + issue + anchor +
                           (1|respid)+ (1|respondent), data = df3)

summary(fit_persptak)


persp_tak_bnp <- ordinal::clmm(movement_3 ~ persp_tak + issue + anchor + (1|respid) + (1|respondent),
                              data = df3, link='logit')
summary(persp_tak_bnp)

```


# H3  Senders who use personal appeals are more persuasive

```{r}
fit_personal_rev <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + issue + anchor +
                           (1|respid)+ (1|respondent), data = df3) 
summary(fit_personal_rev)


fit_personal_rev_bnp <- ordinal::clmm(movement_3 ~ personal_rev + issue + anchor + (1|respid) + (1|respondent),
                              data = df3, link='logit') 
summary(fit_personal_rev_bnp)

```

# H4 Senders who highlight common ground are more persuasive

```{r}
fit_common_ground <- lmer(quarkelt2 ~ quarkelt1 + common_ground + issue + anchor +
                           (1|respid)+ (1|respondent), data = df3)
summary(fit_common_ground)


fit_common_ground_bnp <- ordinal::clmm(movement_3 ~ common_ground + issue + anchor + (1|respid) + (1|respondent),
                              data = df3, link='logit')
summary(fit_common_ground_bnp)


```


# H5 Long messages are more persuasive

```{r}
# Message Length (in words)
fit_length <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords + issue + anchor +
                           (1|respid)+ (1|respondent), data = df3)
summary(fit_length)


# Message Length (in words)
fit_length_bnp <- ordinal::clmm(movement_3 ~ mlengthwords + issue + anchor + (1|respid) + (1|respondent),
                              data = df3, link='logit')

summary(fit_length_bnp)

```




# H6 Messages that took more time to write are more persuasive

```{r}
# Time (in seconds)
fit_time <- lmer(quarkelt2 ~ quarkelt1 + time + issue + anchor +
                           (1|respid)+ (1|respondent), data = df3)
summary(fit_time)

fit_time_bnp <- ordinal::clmm(movement_3 ~ time + issue + anchor + (1|respid) + (1|respondent),
                              data = df3, link='logit')
summary(fit_time_bnp)

```




# H7 Independent leaners more persuasive arguments than pure independents
```{r}
fit_partyintensity_lean <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data =df3[(df3$partyid_cat==1 | df3$partyid_cat==2),])

summary(fit_partyintensity_lean)

partyintensity_lean_bnp <- ordinal::clmm(movement_3 ~ partyid_cat + issue + anchor + (1|respid) + (1|respondent),
                              data =df3[(df3$partyid_cat==1 | df3$partyid_cat==2),], link='logit')
summary(partyintensity_lean_bnp)


```

# H8 Strong party identifiers less persuasive than weak dentifiers
```{r}
fit_partyintensity_sw <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data =df3[(df3$partyid_cat==3 | df3$partyid_cat==4),])

summary(fit_partyintensity_sw)


partyintensity_sw_bnp <- ordinal::clmm(movement_3 ~ partyid_cat + issue + anchor + (1|respid) + (1|respondent),
                              data =df3[(df3$partyid_cat==3 | df3$partyid_cat==4),], link='logit')
summary(partyintensity_sw_bnp)

```


# H9 Affective polarization is associated with lower persuasiveness

```{r}
library(lme4)

fit_affpol <- lmer(quarkelt2 ~ quarkelt1 + affpol + issue + anchor +
                           (1|respid)+ (1|respondent), data = df3)
summary(fit_affpol)

affpol_bnp_1 <- ordinal::clmm(movement_3 ~ affpol + issue + anchor + (1|respid) + (1|respondent),
                              data = df3, link='logit')
summary(affpol_bnp_1)

```

# H10 Interest in politics is associated with greater persuasiveness

```{r}
fit_polintr2 <-  lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + issue + anchor +
                           (1|respid)+ (1|respondent), data = df3)
summary(fit_polintr2)




pol_intr_bnp_2 <- ordinal::clmm(movement_3 ~ pol_intr_full + issue + anchor + (1|respid) + (1|respondent),
                              data = df3, link='logit')
summary(pol_intr_bnp_2)

```

# H11 Political Knowledge 
```{r}
fit_polknow <-  lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + issue + anchor +
                           (1|respid)+ (1|respondent), data = df3)
summary(fit_polknow)


#pol_know_avg    0.06129    0.08844  270.20111   0.693   0.4889    

# 0.4889/2 
# p=0.24445


pol_know_bnp <- ordinal::clmm(movement_3 ~ pol_know_avg + issue + anchor + (1|respid) + (1|respondent),
                              data = df3, link='logit')
summary(pol_know_bnp)

#pol_know_avg  0.107036   0.107251   0.998  0.31828   
#p= 0.15914 (0.31828/2)


```

# H12 Senders who mention specific facts are more persuasive

```{r}
fit_specific_fact <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + issue + anchor +
                           (1|respid)+ (1|respondent), data = df3) 
summary(fit_specific_fact)



fit_specific_fact_bnp <- ordinal::clmm(movement_3 ~ specific_fact + issue + anchor + (1|respid) + (1|respondent),
                              data = df3, link='logit') 
summary(fit_specific_fact_bnp)

```


### H13 Self-Esteem
```{r}
fit_selfest <- lmer(quarkelt2 ~ quarkelt1 + self_est + issue + anchor +
                           (1|respid)+ (1|respondent), data = df3)

summary(fit_selfest)

fit_selfesteem_bnp <- ordinal::clmm(movement_3 ~ self_est + issue + anchor + (1|respid) + (1|respondent),
                              data = df3, link='logit')
summary(fit_selfesteem_bnp)


```


# H14 Attitude Extremity
```{r}
fit_attstrength <-  lmer(quarkelt2 ~ quarkelt1 + att_strength + issue + anchor +
                           (1|respid)+ (1|respondent), data = df3)

summary(fit_attstrength)


fit_attstrength_bnp <- ordinal::clmm(movement_3 ~ att_strength + issue + anchor + (1|respid) + (1|respondent),
                              data = df3, link='logit')
summary(fit_attstrength_bnp)

```



# SI-10: Education and Persuasiveness

# Table A.10.1: Relationship Between Sender Education and Persuasiveness (Study 2)
```{r}

df2$edu <- as.numeric(df2$edu)


range01 <- function(x, ...){(x - min(x, ...)) / (max(x, ...) - min(x, ...))}

df2$edu <- range01(df2$edu, na.rm = T)

edu_senders_2 <- lmer(quarkelt2 ~ quarkelt1 + issue + anchor + edu +
                           (1|respid)+ (1|respondent), data = df2)
summary(edu_senders_2)

```


#Table A.10.2: Hypothesis Tests, Controlling for Receiver Education

```{r}
df2$edu_rec <- as.numeric(df2$edu_rec)
#range01 <- function(x, ...){(x - min(x, ...)) / (max(x, ...) - min(x, ...))}
df2$edu_rec <- range01(df2$edu_rec, na.rm = T)

```


#H1: Need for cognition is associated with greater persuasion
```{r}
fit_nfc <- lmer(quarkelt2 ~ quarkelt1 + nfc + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df2)
cooks_h3 <- as.data.frame(cooks.distance(fit_nfc))

df_estimation_3 <- df2[as.numeric(rownames(cooks_h3)), ]


fit_nfc_est <- lmer(quarkelt2 ~ quarkelt1 + nfc + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_estimation_3)
summary(fit_nfc_est)

cooks_h3 <- as.data.frame(cooks.distance(fit_nfc_est))

mean(cooks_h3$`cooks.distance(fit_nfc_est)`) + 2*sd(cooks_h3$`cooks.distance(fit_nfc_est)`)
#0.09834268


df_reduced_nfc <- df_estimation_3[cooks_h3$`cooks.distance(fit_nfc_est)` < 0.09834268,]

fit_nfc_cooks <- lmer(quarkelt2 ~ quarkelt1 + nfc + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_nfc)

summary(fit_nfc_cooks)

#nfc            0.13439    0.08212  262.63001   1.636  0.10294    

#p=0.051 (0.10294/2)
```


# H2: Perspective taking ability is associated with greater persuasion

```{r}
library(lmerTest)
### Perspective Taking ###

fit_persptak <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df2)
summary(fit_persptak)


cooks_h8 <- as.data.frame(cooks.distance(fit_persptak))

df_estimation_8 <- df2[as.numeric(rownames(cooks_h8)), ]


fit_persptak_est <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_estimation_8)
summary(fit_persptak_est)


cooks_h8 <- as.data.frame(cooks.distance(fit_persptak_est))


mean(cooks_h8$`cooks.distance(fit_persptak_est)`) + 2*sd(cooks_h8$`cooks.distance(fit_persptak_est)`)
#0.09850132

df_reduced_persptak <- df_estimation_8[cooks_h8$`cooks.distance(fit_persptak_est)` < 0.09850132,]

fit_persptak_cooks <- lmer(quarkelt2 ~ quarkelt1 + persp_tak + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_persptak)

summary(fit_persptak_cooks)

#persp_tak      0.14549    0.09102  235.07027   1.598 0.111309  

#p=0.056

```

# H3: Senders who use personal appeals are more persuasive

```{r}
fit_personal_rev <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df2) 
summary(fit_personal_rev)

cooks_h9 <- as.data.frame(cooks.distance(fit_personal_rev))

df_estimation_9 <- df2[as.numeric(rownames(cooks_h9)), ]


fit_personal_rev_est <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_estimation_9)
summary(fit_personal_rev_est)


cooks_h9 <- as.data.frame(cooks.distance(fit_personal_rev_est))


mean(cooks_h9$`cooks.distance(fit_personal_rev_est)`) + 2*sd(cooks_h9$`cooks.distance(fit_personal_rev_est)`)
#0.09787678

df_reduced_personal_rev <- df_estimation_9[cooks_h9$`cooks.distance(fit_personal_rev_est)` < 0.09787678,]


fit_personal_rev_cooks <- lmer(quarkelt2 ~ quarkelt1 + personal_rev + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_personal_rev)

summary(fit_personal_rev_cooks)

#personal_rev1    0.21766    0.06783  310.27880   3.209 0.001471 ** 

```


# H4: Senders who highlight common ground are more persuasive

```{r}
fit_common_ground <- lmer(quarkelt2 ~ quarkelt1 + common_ground + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df2)
summary(fit_common_ground)

cooks_h10 <- as.data.frame(cooks.distance(fit_common_ground))

df_estimation_10 <- df2[as.numeric(rownames(cooks_h10)), ]


fit_av_est <- lmer(quarkelt2 ~ quarkelt1 + common_ground + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_estimation_10)
summary(fit_av_est)

cooks_h10 <- as.data.frame(cooks.distance(fit_av_est))


mean(cooks_h10$`cooks.distance(fit_av_est)`) + 2*sd(cooks_h10$`cooks.distance(fit_av_est)`)
#0.09660175

df_reduced_av <- df_estimation_10[cooks_h10$`cooks.distance(fit_av_est)` < 0.09660175,]


fit_av_cooks <- lmer(quarkelt2 ~ quarkelt1 + common_ground + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_av)

summary(fit_av_cooks)

#common_ground1    0.16399    0.04458  241.21632   3.679 0.000289 ***



```


# H5: Long messages are more persuasive

```{r}
# Message Length (in words)
fit_length <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df2)
summary(fit_length)

cooks_h11 <- as.data.frame(cooks.distance(fit_length))

df_estimation_11 <- df2[as.numeric(rownames(cooks_h11)), ]


fit_length_est <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_estimation_11)
summary(fit_length_est)

cooks_h11 <- as.data.frame(cooks.distance(fit_length_est))


mean(cooks_h11$`cooks.distance(fit_length_est)`) + 2*sd(cooks_h11$`cooks.distance(fit_length_est)`)
#0.09767898

df_reduced_length <- df_estimation_11[cooks_h11$`cooks.distance(fit_length_est)` < 0.09767898,]


fit_length_cooks <- lmer(quarkelt2 ~ quarkelt1 + mlengthwords + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_length)

summary(fit_length_cooks)
#mlengthwords    0.40449    0.09601  287.03820   4.213 3.38e-05 ***




```


# H6: Messages that took more time to write are more persuasive

```{r}

# Time (in seconds)
fit_time <- lmer(quarkelt2 ~ quarkelt1 + time + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df2)

cooks_h12 <- as.data.frame(cooks.distance(fit_time))

df_estimation_12 <- df2[as.numeric(rownames(cooks_h12)), ]


fit_time_est <- lmer(quarkelt2 ~ quarkelt1 + time + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_estimation_12)

cooks_h12 <- as.data.frame(cooks.distance(fit_time_est))


mean(cooks_h12$`cooks.distance(fit_time_est)`) + 2*sd(cooks_h12$`cooks.distance(fit_time_est)`)
#0.09837057

df_reduced_time <- df_estimation_12[cooks_h12$`cooks.distance(fit_time_est)` < 0.09837057,]


fit_time_cooks <- lmer(quarkelt2 ~ quarkelt1 + time + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_time)

summary(fit_time_cooks)
#time         2.959e-01  1.244e-01  2.599e+02   2.379  0.01807 *  

#p=0.009 (0.01807/2)
```


#H7: Independent leaners more persuasive arguments than pure independents
```{r}
# Leaners better at persuading relative to pure independents

df_partyintensity_1_2 <- subset(df2, partyid_cat == 1 | partyid_cat == 2)


fit_partyintensity_lean <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + edu_rec + (1|respid) + (1|respondent), 
                                data =df_partyintensity_1_2)

summary(fit_partyintensity_lean)


cooks_h6 <- as.data.frame(cooks.distance(fit_partyintensity_lean))

df_estimation_6 <- df_partyintensity_1_2[as.numeric(rownames(cooks_h6)), ]


fit_partyint_lean_est <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + edu_rec + (1|respid) + (1|respondent), 
                                data = df_estimation_6)

summary(fit_partyint_lean_est)

cooks_h6 <- as.data.frame(cooks.distance(fit_partyint_lean_est))

mean(cooks_h6$`cooks.distance(fit_partyint_lean_est)`) + 2*sd(cooks_h6$`cooks.distance(fit_partyint_lean_est)`)
#0.2050807

df_reduced_partyint_lean <- df_estimation_6[cooks_h6$`cooks.distance(fit_partyint_lean_est)` < 0.2050807,]

fit_partyint_lean_cooks <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_partyint_lean)

summary(fit_partyint_lean_cooks)

#partyid_cat2    0.11331    0.10628   70.48659   1.066   0.2900    

```

#H8: Strong party identifiers less persuasive than weak dentifiers
```{r}

library(lmerTest)

df_partyintensity_3_4 <- subset(df2, partyid_cat == 3 | partyid_cat == 4)

fit_partyintensity_sw <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + edu_rec + 
                                  issue + anchor + (1|respid) + (1|respondent), 
                                data = df_partyintensity_3_4)

summary(fit_partyintensity_sw)


cooks_h5 <- as.data.frame(cooks.distance(fit_partyintensity_sw))

df_estimation_5 <- df_partyintensity_3_4[as.numeric(rownames(cooks_h5)), ]


fit_partyint_est <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + 
                                  issue + anchor + edu_rec + (1|respid) + (1|respondent), 
                                data = df_estimation_5)

summary(fit_partyint_est)

cooks_h5 <- as.data.frame(cooks.distance(fit_partyint_est))

mean(cooks_h5$`cooks.distance(fit_partyint_est)`) + 2*sd(cooks_h5$`cooks.distance(fit_partyint_est)`)
#0.1218674

df_reduced_partyint <- df_estimation_5[cooks_h5$`cooks.distance(fit_partyint_est)` < 0.1218674,]

fit_partyint_cooks <- lmer(quarkelt2 ~ quarkelt1 + partyid_cat + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_partyint)

summary(fit_partyint_cooks)

#partyid_cat4   -0.01394    0.04650  196.97450  -0.300   0.7647    

#p=0.382 (0.7647/2)
```




#H9: Affective polarization is associated with lower persuasiveness

```{r}
library(lme4)

fit_affpol <- lmer(quarkelt2 ~ quarkelt1 + affpol + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df2)
summary(fit_affpol)

cooks_h7 <- as.data.frame(cooks.distance(fit_affpol))

df_estimation_7 <- df2[as.numeric(rownames(cooks_h7)), ]


fit_affpol_est <- lmer(quarkelt2 ~ quarkelt1 + affpol + 
                                  issue + anchor + edu_rec + (1|respid) + (1|respondent), 
                                data = df_estimation_7)

summary(fit_affpol_est)

cooks_h7 <- as.data.frame(cooks.distance(fit_affpol_est))

mean(cooks_h7$`cooks.distance(fit_affpol_est)`) + 2*sd(cooks_h7$`cooks.distance(fit_affpol_est)`)
#0.09903465

df_reduced_affpol <- df_estimation_7[cooks_h7$`cooks.distance(fit_affpol_est)` < 0.09903465,]

fit_affpol_cooks <- lmer(quarkelt2 ~ quarkelt1 + affpol + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_affpol)
summary(fit_affpol_cooks)
#affpol         0.01522    0.06301  257.51559   0.242  0.80928    
#p=0.405 (0.809/2)
```





#H10: Interest in politics is associated with greater persuasiveness

```{r}

fit_polintr2 <-  lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df2)

cooks_h2 <- as.data.frame(cooks.distance(fit_polintr2))

df_estimation_2 <- df2[as.numeric(rownames(cooks_h2)), ]


fit_polintr_est <- lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + issue + anchor +edu_rec +
                           (1|respid)+ (1|respondent), data = df_estimation_2)

cooks_h2 <- as.data.frame(cooks.distance(fit_polintr_est))

mean(cooks_h2$`cooks.distance(fit_polintr_est)`) + 2*sd(cooks_h2$`cooks.distance(fit_polintr_est)`)
#0.09912271


df_reduced_pi <- df_estimation_2[cooks_h2$`cooks.distance(fit_polintr_est)` < 0.09912271,]

fit_pi_cooks <- lmer(quarkelt2 ~ quarkelt1 + pol_intr_full + issue + anchor +edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_pi)

summary(fit_pi_cooks)

#pol_intr_full    0.04454    0.08057  264.35074   0.553  0.58083  

```

#H11: Political knowledge is associated with greater persuasiveness

```{r}

fit_polknow <-  lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df2)

summary(fit_polknow)

cooks_h1 <- as.data.frame(cooks.distance(fit_polknow))

df_estimation_1 <- df2[as.numeric(rownames(cooks_h1)), ]


fit_polknow_est <- lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_estimation_1)

cooks_h1 <- as.data.frame(cooks.distance(fit_polknow_est))

mean(cooks_h1$`cooks.distance(fit_polknow_est)`) + 2*sd(cooks_h1$`cooks.distance(fit_polknow_est)`)
#0.1001062

df_reduced_pk <- df_estimation_1[cooks_h1$`cooks.distance(fit_polknow_est)` < 0.1001062,]

fit_pk_cooks <- lmer(quarkelt2 ~ quarkelt1 + pol_know_avg + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_pk)

summary(fit_pk_cooks)

#pol_know_avg  6.307e-02  6.323e-02  2.639e+02   0.998  0.31943    

```


#H12: Senders who mention specific facts are more persuasive

```{r}
fit_specific_fact <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df2) 
summary(fit_specific_fact)

cooks_h4 <- as.data.frame(cooks.distance(fit_specific_fact))

df_estimation_4 <- df2[as.numeric(rownames(cooks_h4)), ]


fit_fact_est <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_estimation_4)
summary(fit_fact_est)

cooks_h4 <- as.data.frame(cooks.distance(fit_fact_est))

mean(cooks_h4$`cooks.distance(fit_fact_est)`) + 2*sd(cooks_h4$`cooks.distance(fit_fact_est)`)
#0.09727215


df_reduced_fact <- df_estimation_4[cooks_h4$`cooks.distance(fit_fact_est)` < 0.09727215,]

fit_fact_cooks <- lmer(quarkelt2 ~ quarkelt1 + specific_fact + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_fact)

summary(fit_fact_cooks)

#specific_fact1    0.08914    0.07174  250.52786   1.243  0.21519    

#p=0.108
```


#H13: Self Esteem
```{r}
library(lmerTest)
### Self Esteem ###

fit_selfest <- lmer(quarkelt2 ~ quarkelt1 + self_est + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df2)

summary(fit_selfest)

cooks_selfest1 <- as.data.frame(cooks.distance(fit_selfest))

df_estimation_selfest1 <- df2[as.numeric(rownames(cooks_selfest1)), ]


fit_selfest1_est <- lmer(quarkelt2 ~ quarkelt1 + self_est + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_estimation_selfest1)
summary(fit_selfest1_est)


cooks_selfest1 <- as.data.frame(cooks.distance(fit_selfest1_est))


mean(cooks_selfest1$`cooks.distance(fit_selfest1_est)`) + 2*sd(cooks_selfest1$`cooks.distance(fit_selfest1_est)`)
#0.09818512

df_reduced_selfest1 <- df_estimation_selfest1[cooks_selfest1$`cooks.distance(fit_selfest1_est)` < 0.09818512,]

fit_selfest_1_cdr <- lmer(quarkelt2 ~ quarkelt1 + self_est + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_selfest1)

summary(fit_selfest_1_cdr)

#self_est      -0.12720    0.07999  295.89303  -1.590  0.11286    
  

#p=0.05643 (0.11286/2) 


```


#H14: Issue Attitude Extremity
```{r}
### Attitude Strength ###
### Analysis Attitude Strength
fit_attstrength <-  lmer(quarkelt2 ~ quarkelt1 + att_strength + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df2)

summary(fit_attstrength)

cooks_attstrength <- as.data.frame(cooks.distance(fit_attstrength))

df_estimation_attstrength <- df2[as.numeric(rownames(cooks_attstrength)), ]


fit_attstrength_est <- lmer(quarkelt2 ~ quarkelt1 + att_strength + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_estimation_attstrength)
summary(fit_attstrength_est)


cooks_attstrength <- as.data.frame(cooks.distance(fit_attstrength_est))


mean(cooks_attstrength$`cooks.distance(fit_attstrength_est)`) + 2*sd(cooks_attstrength$`cooks.distance(fit_attstrength_est)`)
#0.09901812

df_reduced_attstrength <- df_estimation_attstrength[cooks_attstrength$`cooks.distance(fit_attstrength_est)` < 0.09901812,]

fit_attstrength_cooks <- lmer(quarkelt2 ~ quarkelt1 + att_strength + issue + anchor + edu_rec +
                           (1|respid)+ (1|respondent), data = df_reduced_attstrength)

summary(fit_attstrength_cooks)

#att_strength -6.453e-02  5.717e-02  2.651e+02  -1.129  0.26001    
   

#p = 0.13 (0.26001/2)
```

